{% from "__autoindex__/macros.html" import entry, thead, breadcrumb
   with context %}

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Index of {{ curdir.path }}</title>
  {% block meta %}
    <link rel="stylesheet" type="text/css"
      href="{{ url_for('__autoindex__.static', filename='autoindex.css') }}" />
  {% endblock %}
</head>
<body>
  <form method="get" action="{{request.url}}" target="_blank">
      <input type="text" name="search" style="width: 100px; height: 30px">
      <input type="submit" value="search" style="height: 30px">
  </form>
  {% block header %}{% endblock %}
  {% block table %}
    <table>
      <thead>
        {{ thead() }}
        {% if not curdir.is_root() %}
          <tr>
            <td class="breadcrumb" colspan="4">
              <h1>{{ breadcrumb(curdir) }}</h1>
            </td>
          </tr>
        {% endif %}
      </thead>
      <tbody class="tableContainer">
          {% for ent in entries %}
              {{ entry(ent) }}
          {% endfor %}
      </tbody>
    </table>
  {% endblock %}
  {% block footer %}
    {% set env = request.environ %}
    <address>{{ env.SERVER_SOFTWARE }}
      Server at {{ env.HTTP_HOST }}
      Port {{ env.SERVER_PORT }}</address>
  {% endblock %}
  <script src="{{ url_for('__autoindex__.static', filename='js/infinite-scroll.pkgd.js') }}"></script>
  <script src="{{ url_for('__autoindex__.static', filename='js/jquery.js') }}"></script>
  <script>
    var infScroll = new InfiniteScroll( '.tableContainer', {
     path: function() {
        if("{{request.url}}".includes('?')) {
            return "{{request.url}}" + "&start=" + ( ( this.loadCount + 1 ) * {{pageSize}});
        }else{
            return "{{request.url}}" + "?start=" + ( ( this.loadCount + 1 ) * {{pageSize}});
        }
      },
      append: '.isTr'
    });
  </script>
</body>
</html>
